﻿<Window x:Class="StartingFromScratch.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:viewModels="clr-namespace:StartingFromScratch.ViewModels"
        xmlns:views="clr-namespace:StartingFromScratch.Views"
        xmlns:local="clr-namespace:StartingFromScratch"
        Title="Simple Network Editor for LSE" Height="350" Width="525"
        FontFamily="Segoe UI" FontWeight="Light" FontSize="12">
    <Window.DataContext>
        <viewModels:MainWindowViewModel/>
    </Window.DataContext>
    <Window.Resources>
        
        <!-- Template Selector for Main Window -->
        <local:MainWindowViewTemplateSelector x:Key="MainWindowViewTemplateSelector" />
        
        <!-- DataTemplate for Database Connection View -->
        <!--<DataTemplate DataType="{x:Type views:DatabaseConnectionView}" x:Key="DatabaseConnectionViewTemplate">
            <views:DatabaseConnectionView />
        </DataTemplate>-->

        <!-- DataTemplate for Network Tree View -->
        <DataTemplate DataType="{x:Type views:NetworkTreeView}" x:Key="NetworkTreeViewTemplate">
            <views:NetworkTreeView />
        </DataTemplate>

        <!-- DataTemplate for Record Detail View -->
        <DataTemplate DataType="{x:Type views:RecordDetailView}" x:Key="RecordDetailViewTemplate">
            <views:RecordDetailView />
        </DataTemplate>
        
        <Style TargetType="{x:Type StatusBarItem}">
            <Setter Property="FontFamily" Value="Segoe UI" />
            <Setter Property="FontWeight" Value="Light" />
            <Setter Property="FontSize" Value="14" />
        </Style>
        
        <Style TargetType="{x:Type MenuItem}">
            <Setter Property="Header" Value="{Binding Path=Text}"/>
            <Setter Property="Command" Value="{Binding Path=Command}"/>
            <Setter Property="FontFamily" Value="Segoe UI" />
            <Setter Property="FontWeight" Value="Normal" />
            <Setter Property="IsEnabled" Value="{Binding Path=IsEnabled}" />
            <Setter Property="IsCheckable" Value="{Binding Path=IsCheckable}" />
            <Setter Property="IsChecked" Value="{Binding Path=IsChecked}" />
        </Style>
        
        <HierarchicalDataTemplate DataType="{x:Type viewModels:MenuItemViewModel}" ItemsSource="{Binding Path=Children}"/>
        
    </Window.Resources>
    <DockPanel>
        <Menu DockPanel.Dock="Top" ItemsSource="{Binding Path=MenuBarItems}"/>
        <StatusBar DockPanel.Dock="Bottom">
            <StatusBar.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="10"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="10"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                    </Grid>
                </ItemsPanelTemplate>
            </StatusBar.ItemsPanel>
            <StatusBarItem>
                <TextBlock Width="Auto" Text="{Binding ActionStatus}"/>
            </StatusBarItem>
            <StatusBarItem Grid.Column="1">
                <Separator/>
            </StatusBarItem>
            <StatusBarItem Grid.Column="2">
                <TextBlock Width="Auto" Text="{Binding CommunicationStatus}" />
            </StatusBarItem>
            <StatusBarItem Grid.Column="3">
                <Separator/>
            </StatusBarItem>
            <StatusBarItem Grid.Column="4">
                <TextBlock Width="Auto" Text="{Binding SpecialStatus}" />
            </StatusBarItem>
        </StatusBar>
        
        <Grid HorizontalAlignment="Stretch">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="300" Width="*" />
                <ColumnDefinition Width="2.5*" />
            </Grid.ColumnDefinitions>
            
            <!-- Network Tree View -->
            <ContentControl Grid.Column="0" Content="{Binding NetworkTree}" ContentTemplateSelector="{StaticResource MainWindowViewTemplateSelector}"/>
            
            <GridSplitter Width="2" Background="Gray" VerticalAlignment="Stretch" />

            <!-- Record Detail View -->
            <ContentControl Grid.Column="1" Content="{Binding RecordDetail}" ContentTemplateSelector="{StaticResource MainWindowViewTemplateSelector}"/>
        </Grid>
    </DockPanel>
</Window>
